package com.opNaga.bpmn.actions.edit;

import com.opNaga.bpmn.panel.BPMPPanel;
import y.view.Graph2DClipboard;
import y.view.Graph2DView;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.Dictionary;
import java.util.Hashtable;

/**
 * User: Junyi BEI
 * Date: 20/03/2012
 * Time: 15:52
 */
public class Paste extends AbstractAction {
  private JTabbedPane tabbedPane;
  private Dictionary<Integer, Action> pasteActions = new Hashtable<Integer, Action>();

  public Paste(JTabbedPane tabbedPane) {
    this.tabbedPane = tabbedPane;
    int tabCount = tabbedPane.getTabCount();
    for(int t = 0; t < tabCount; t++) {
      BPMPPanel bpmpPanel = (BPMPPanel) tabbedPane.getComponentAt(t);
      Graph2DClipboard clipboard = bpmpPanel.getClipboard();
      pasteActions.put(t, clipboard.getPasteAction());
    }
  }

  public void actionPerformed(ActionEvent e) {
    pasteActions.get(tabbedPane.getSelectedIndex()).actionPerformed(e);
  }
}